package org.footballmanager.pandafootball.system.form.impl;

import lombok.Getter;
import lombok.Setter;
import org.footballmanager.pandafootball.system.domain.FootSj;
import org.footballmanager.pandafootball.system.domain.enums.BSJC;
import org.footballmanager.pandafootball.system.domain.enums.SJZT;
import org.footballmanager.pandafootball.system.form.SearchForm;
import org.springframework.util.StringUtils;
import tk.mybatis.mapper.entity.Example;

import java.io.Serializable;

@Setter
@Getter
public class FootSjSearchForm extends SearchForm implements Serializable {
    private static final long serialVersionUID = 8090668615941861539L;
    protected String sjbm;
    protected BSJC bsjc;
    protected SJZT sjzt;

    public Example buildSearchCommond() {
        Example example = new Example(FootSj.class);
        Example.Criteria criteria = example.createCriteria();
        if (!StringUtils.isEmpty(sjbm)) {
            criteria.andEqualTo("sjbm", sjbm.trim());
        }
        if (bsjc != null) {
            criteria.andEqualTo("bsjc", bsjc);
        }
        if (sjzt != null) {
            criteria.andEqualTo("sjzt", sjzt);
        }
        criteria.andEqualTo("delFlag", 0);
        example.orderBy("sjbm").desc();
        return example;
    }

}
